home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 1999-08-25 | 2.8 KB | 84 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "VBSnow"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- ' Maximum number of flakes, alter for more or less flakes
- Private Const NUMFLAKES = 100
- ' Alter SCREENX and SCREENY to desired screen width and height
- Private Const SCREENX = 320
- Private Const SCREENY = 240
-
- ' The actual type defining a single flake
- Private Type tFlake
- X As Integer
- Y As Integer
- N As Integer
- End Type
-
- ' An array of flakes
- Private Flakes(NUMFLAKES) As tFlake
-
- Private Sub Class_Initialize()
- For i = LBound(Flakes) To UBound(Flakes)
- Randomize
- Flakes(i).X = Int(Rnd() * (SCREENX - 1))
- Flakes(i).Y = Int(Rnd() * (SCREENY - 1))
- Flakes(i).N = Int(Rnd() * 4) + 1
- Next i
- End Sub
-
- Public Sub ReInit()
- Call Class_Initialize
- End Sub
-
- Public Sub DrawFlakes(frm As Form)
- Dim btm As Long, rgt As Long, lft As Long
-
- For i = 0 To UBound(Flakes)
- ' Read bottom, lower left and lower right pixels
- btm = GetPixel(frm.hDC, Flakes(i).X, Flakes(i).Y + 1)
- lft = GetPixel(frm.hDC, Flakes(i).X - 1, Flakes(i).Y + 1)
- rgt = GetPixel(frm.hDC, Flakes(i).X + 1, Flakes(i).Y + 1)
-
- ' Delete current position
- SetPixel frm.hDC, Flakes(i).X, Flakes(i).Y, RGB(0, 0, 0)
-
- If Flakes(i).Y >= SCREENY - 1 Then
- SetPixel frm.hDC, Flakes(i).X, Flakes(i).Y, RGB(Flakes(i).N * 51, Flakes(i).N * 51, Flakes(i).N * 51)
- Flakes(i).Y = 0
- Flakes(i).X = Int(Rnd() * (SCREENX - 1))
- End If
- If btm = RGB(0, 0, 0) Then
- Flakes(i).Y = Flakes(i).Y + 1
- SetPixel frm.hDC, Flakes(i).X, Flakes(i).Y, RGB(Flakes(i).N * 51, Flakes(i).N * 51, Flakes(i).N * 51)
- GoTo Done
- Else
- If rgt = RGB(0, 0, 0) Then
- Flakes(i).X = Flakes(i).X + 1
- Flakes(i).Y = Flakes(i).Y + 1
- SetPixel frm.hDC, Flakes(i).X, Flakes(i).Y, RGB(Flakes(i).N * 51, Flakes(i).N * 51, Flakes(i).N * 51)
- GoTo Done
- ElseIf lft = RGB(0, 0, 0) Then
- Flakes(i).X = Flakes(i).X - 1
- Flakes(i).Y = Flakes(i).Y + 1
- SetPixel frm.hDC, Flakes(i).X, Flakes(i).Y, RGB(Flakes(i).N * 51, Flakes(i).N * 51, Flakes(i).N * 51)
- GoTo Done
- Else
- SetPixel frm.hDC, Flakes(i).X, Flakes(i).Y, RGB(Flakes(i).N * 51, Flakes(i).N * 51, Flakes(i).N * 51)
- Flakes(i).Y = 0
- GoTo Done
- End If
- End If
- Done:
- Next i
- End Sub
-